package com.ys.filelib.filedialog;

import com.ys.filelib.filedialog.entity.FTPFileBean;

import java.io.File;

public class FileInfo {
    public File file;
    public FTPFileBean ftpFile;
    public boolean check;

    public FileInfo() {
    }

    public FileInfo(File file) {
        this.file = file;
    }

    public FileInfo(FTPFileBean ftpFile) {
        this.ftpFile = ftpFile;
    }

    public boolean isDirectory() {
        if (file != null) {
            return file.isDirectory();
        }
        return ftpFile.isDirectory();
    }

    public String getPath() {
        if (file != null) {
            return file.getAbsolutePath();
        }
        return ftpFile.getPath();
    }

    public String getName() {
        if (file != null) {
            return file.getName();
        }
        return ftpFile.getName();
    }

    public long getTime() {
        if (file != null) {
            return file.lastModified();
        }
        return ftpFile.getCreateTime();
    }

    public long getSize() {
        if (file != null) {
            return file.length();
        }
        return ftpFile.getSize();
    }

    public String getKey() {
        if (ftpFile != null) {
            return ftpFile.host + ftpFile.port + ftpFile.username + getPath();
        }
        return null;
    }
}
